package com.khyr.controller;

import com.khyr.Service.OrderService;
import com.khyr.vo.OrderChargeRequestVo;
import com.khyr.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author 宋一恒
 * @version 1.0
 */
@RestController
@RequestMapping("/charge/dispenseMedicine")
public class OrderController {
    @Autowired
    private OrderService orderService;

    //创建订单
    @PostMapping("/createNavite/{orderNo}")
    public R<Map> createNavite(@PathVariable String orderNo){
        return orderService.createNavite(orderNo);
    }

    //根据订单状态查询微信支付情况
    @PostMapping("/queryPayStatus/{orderNo}")
    public R<Map> queryPayStatus(@PathVariable String orderNo){
        return orderService.queryPayStatus(orderNo);
    }

    //生成订单,前端把挂号单id传过来
    @PostMapping("/createOrder")
    public R createOrder(@RequestBody OrderChargeRequestVo orderChargeRequestVo){
        return orderService.createOrder(orderChargeRequestVo);
    }

    @PostMapping("/wxPay/{chId}")
    public R createOrder(@PathVariable String chId ){
        return orderService.wxPay(chId);
    }

    //手机端查询订单状态
    @PostMapping("/queryWxPayStatus/{chId}")
    public R queryWxPayStatus(@PathVariable String chId){
        return orderService.queryWxPayStatus(chId);
    }

    //时间结束后，修改订单状态
    @PutMapping("/updateOrderStatus/{orderNo}")
    public R updateOrderStatus(@PathVariable String orderNo){
        return orderService.updateOrderStatus(orderNo);
    }
}
